/*
 * @Author: Bennent_G
 * @Date: 2025-01-02 12:14:48
 * @LastEditTime: 2025-03-21 10:18:44
 * @Description:
 */
// src/hooks/useRouteInfo.ts
import { ref, watch, computed } from 'vue';
import { useRoute } from 'vue-router';

export default function useRouteHook() {
	const route = useRoute();
	const currentRoute = ref(route);

	const parentRoute = computed(() => {
		const matchedRoutes = route.matched;
		return matchedRoutes.length > 1 ? matchedRoutes[matchedRoutes.length - 2] : null;
	});

	watch(
		() => route.path,
		() => {
			currentRoute.value = route;
		},
		{ immediate: true }
	);

	return {
		currentRoute,
		parentRoute,
	};
}
